<?php

namespace Acme\SecurityBundle\Controller;

use Symfony\Component\HttpFoundation\Response;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;

use Symfony\Component\Security\Core\SecurityContext;


class SecurityController extends Controller
{
    /**
     * @Route("/login", name="AcmeSecurityBundle_Login")
     * @Template()
     */
	public function loginAction()
    {
        $request = $this->getRequest();
        $session = $request->getSession();

        // get the login error if there is one
        if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
            $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
        } else {
            $error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
        }

        return array(
            'last_username' => $session->get(SecurityContext::LAST_USERNAME),  // last username entered by the user
            'error' => $error,
        );
    }
    
    /**
     * @Route("/login_check", name="AcmeSecurityBundle_LoginCheck")
     */
    public function loginCheckAction()
    {
    }
    
    /**
     * @Route("/logout", name="AcmeSecurityBundle_Logout")
     */
    public function logoutAction()
    {
    }
}